#!/bin/bash

# 检查当前IP转发状态
if [[ $(sysctl -n net.ipv4.ip_forward) -eq 0 ]; then
    echo "通过：IPv4转发已禁用"
else
    echo "失败：IPv4转发未禁用"
    exit 1
fi

if [[ $(sysctl -n net.ipv6.conf.all.forwarding) -eq 0 ]]; then
    echo "通过：IPv6转发已禁用"
else
    echo "失败：IPv6转发未禁用"
    exit 1
fi

# 检查永久配置
if grep -q "^net.ipv4.ip_forward=0" /etc/sysctl.conf; then
    echo "通过：IPv4永久配置已正确设置"
else
    echo "失败：IPv4永久配置未正确设置"
    exit 1
fi
if grep -q "^net.ipv6.conf.all.forwarding=0" /etc/sysctl.conf; then
    echo "通过：IPv6永久配置已正确设置"
else
    echo "失败：IPv6永久配置未正确设置"
    exit 1
fi